function list_init() {
	if(typeof(platId) != 'undefined')
	{
		$('select[name="platId"]').val(platId);
		getParentClass(platId);
	}
	if(typeof(classPid) != 'undefined')
	{
		getChildClass(classPid);
	}

	$('select[name="classPid"]').change(function(){
		var curv = $(this).val();
		getChildClass(curv);
	});
	
	$('select[name="platId"]').change(function(){
		var curv = $(this).val();
		getParentClass(curv);
	});
	
}
function getChildClass(pid){
	$.post("/aj_powerlist.php?action=getchild&pid="+pid+"&platid="+$('select[name="platId"]').val(),"",function(rs){
		var child = eval("("+rs+")");
		$('select[name="classCid"]').html('');
		var op = "<option value=-1>全部</option>";
		if(!child.error){
			$.each(child, function(i,n){
				op +="<option value="+n.cid+">"+n.title+"</option>";
			});
		}
		$('select[name="classCid"]').html(op);
		if(typeof(depopt_select)!="undefined"){
			$('select[name="classCid"]').val(depopt_select.sid);
		}
		if(typeof(classCid) != 'undefined')
		{
			$('select[name="classCid"]').val(classCid);
		}
		
});
}
function getParentClass(platid){
	$.post("/aj_powerlist.php?action=getparent&platid="+platid,"",function(rs){
		var parclass = eval("("+rs+")");
		var op = "<option value=-1>全部</option>";
		if(parclass && parclass.error != 'undefined'){
			$.each(parclass, function(i,n){
				if(n.plat_key == platid)
				{
					op +="<option value="+n.cid+">"+n.title+"</option>"; 
				}
			});
		}
		$('select[name="classPid"]').html(op);
		if(typeof(depopt_select)!="undefined"){
			$('select[name="classPid"]').val(depopt_select.pid);
			getChildClass(depopt_select.pid);
		}
		if(typeof(classPid) != 'undefined')
		{
			$('select[name="classPid"]').val(classPid);
		}
	});
}

$(document).ready(function(){
	list_init();
});
